<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="h" uri="/syzg-html"%>
<!DOCTYPE html>
<%
	String realPath = request.getContextPath();   
%>
<html>
	<head>
		<%@ include file="/base/jsp/common/CommonListTop.jsp"%>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<title>新闻编辑-新闻列表</title>
		<link href="${ctx}/base/css/common.css" rel="stylesheet" type="text/css" />
		<link href="${ctx}/base/css/${customTheme}.css" rel="stylesheet" type="text/css" />
		<script src="${ctx}/base/js/base.js" type="text/javascript"></script>
		<script src="${ctx}/base/js/common/FormFunction.js" type="text/javascript"></script>
		<%-- <script src="${ctx}/baseNew/plugins/jQuery/jQuery-2.2.0.min.js"></script> --%>
		<script src="${ctx}/zenithsun/js/jquery-1.9.1.min.js"></script>
		<link href="${ctx}/baseNew/bootstrap/css/bootstrap.min.css" rel="stylesheet">
		<script src="${ctx}/baseNew/bootstrap/js/bootstrap.js" type="text/javascript"></script>
    	<link href="${ctx}/baseNew/other/css/bootstrap-datetimepicker.min.css" rel="stylesheet" media="screen">
		<script src="${ctx}/baseNew/other/js/bootstrap-datetimepicker.js" type="text/javascript"></script>
		<script src="${ctx}/baseNew/other/js/locales/bootstrap-datetimepicker.zh-CN.js" type="text/javascript"></script>
		<link rel="stylesheet" href="${ctx}/baseNew/dist/css/AdminLTE.min.css">
  		<script src="${ctx}/baseNew/other/js/bootbox.min.js" type="text/javascript"></script>
  		<link rel="stylesheet" href="${ctx}/baseNew/validator/css/bootstrapValidator.css"/>
		<script type="text/javascript" src="${ctx}/baseNew/validator/js/bootstrapValidator.js"></script>
		<script src="${ctx}/zenithsun/news/newsinfo/js/newsInfo.js" type="text/javascript"></script>
		<link rel="stylesheet" href="${ctx}/base/imgsel/css/style.css"/>
		<%--新增样式处理 start--%>
		<link rel="stylesheet" href="${ctx}/zenithsun/css/admin-imgList.css"/>
		<script type="text/javascript" src="${ctx}/zenithsun/js/ModalUtil.js"></script>
		<!-- 公用的按钮函数 -->
		<script>
			var realPath = "<%=realPath%>";
			var addUrl = "${ctx}/path/newsinfo/initNewsinfo";//表单列表add 的url地址
			var delUrl = "${ctx}/path/newsinfo/delNewsinfo";//表单列表del的url地址
			var viewUrl = "${ctx}/path/newsinfo/viewNewsinfo";//表单列表view的url地址
			var editUrl = "${ctx}/path/newsinfo/editNewsinfo";//表单列表edit的url地址
			var listUrl = "${ctx}/path/newsinfo/listNewsinfo";//表单列表list 的url地址,用来作为搜索地址
			var saveAddUrl = "${ctx}/path/newsinfo/addNewsinfo";//表单列表save的url地址
			var saveEditUrl = "${ctx}/path/newsinfo/modNewsinfo";//表单列表save的url地址
			$(function () {
				doLoadNewsInfo();
				//绑定回车搜索
				$("#searchValue_title_").keyup(function(){
					if(event.keyCode==13){
						doLoadNewsInfo();
					}
				});
    		});
			function defaultEvent(eventType,width,height) {
				//FormFunction.defaultEvent(eventType,width,height);//默认的处理函数，需自定义时自己写 在PublicFunction.js里
				doLoadNewsInfo();
			}
			
			function showAddModal(url,type){
				var temp = url;
				if(!temp)temp = addUrl;
				temp = temp + "?type=" + type;
				$("#myDlg").load(temp,function(){
					$('#addModal').modal("show");
				});
			}
			//此为图片列表鼠标经过时编辑事件
			function mve(obj){
				$(obj).find(".j-popShow").show();
			}
			//此为图片列表鼠标经过时删除事件
			function mot(obj){
				$(obj).find(".j-popShow").hide();
			}
			/* $(".j-popShow").click(function(){
				mck($(this));
			}); */
			//此为图片列表鼠标经过时点击选中事件
			function mck(obj){
				//$(obj).find("div").toggleClass('selected');
				var objBtn = $(obj).siblings().find(".j-selectId");
				var objBtnVal = objBtn.val();
				if(objBtnVal=="true"){
					objBtn.val(false);
					$(obj).parents("li").removeClass('selected');
		    		$(obj).parents(".select").removeClass('selected');
				} else if(objBtnVal=="false") {
					objBtn.val(true);
					if ($(obj).parents("li.selected").length == 0) {
					    $(obj).parents("li").addClass('selected');
					    $(obj).parents(".select").addClass('selected');
					}
				}
				//counter();
				//alert(checkItem.id+":"+checkItem.checked);
			}
			var newsColumnsId = "",newsType = "";
			function search(cId) {
				pageNo = 1 ;
				if(newsColumnsId == cId){newsColumnsId = "";}else{newsColumnsId = cId;}
				doLoadNewsInfo();
			}
			function searchByType(type,$this){
				pageNo = 1 ;
				if(newsType == type){newsType = "";}else{newsType = type;}
				doLoadNewsInfo();
				$($this).siblings().removeClass("onCure");
				$($this).addClass("onCure");
			}
			//全选功能
			function selectAll(t){
				var selectedRow = $("div[name='liSelectItem']");
				for (var i=0;i<selectedRow.length;i++){
					var selectItem=selectedRow[i];
					if(selectItem!=undefined){
						selectItem=$(selectItem);
						mck(selectItem);
					}
				}
				//改变按钮的内容
				t=$(t);
				if(t.html()=="<i class=\"fa fa-check-square\"></i>全部选择"){
					t.html("<i class=\"fa fa-square\"></i>取消全选");
				}else{
					t.html("<i class=\"fa fa-check-square\"></i>全部选择");
				}
			}
			function noImage750(t){
				t.src=realPath+"/zenithsun/news/mobile/images/default-bg750x500.png"; 
				t.onerror=null;
			}
		</script>
	</head>
	<body class="rightBody">
		<div class="form-inline">
			<table width="100%" class="title" border="0" cellspacing="0" cellpadding="0">
				<tr>
				  <th colspan="2">
				    <img src="${ctx}/zenithsun/images/back.png" width="26" height="26" alt="图标 " class="icon" />
					<em class="headTips">图片新闻网管理</em> &gt; 新闻编辑
				  </th>
				</tr>
				<tr>
				<td colspan="2">
					  <ul class="nav nav-pills">
					  <c:forEach items="${newsColumnsList }" var="newsColumns">
						  <li role="presentation"><a href="javascript:search('${newsColumns.id }');">${newsColumns.name }</a></li>
					  </c:forEach>
					  </ul>
					</td>
				</tr>
				<tr>
				  <td>
				    <div class="form-group">
					  <label class="control-label sr-only" for="searchValue_'title'_">search</label>
					  <input type="hidden" name="searchValue['type']" id="searchValue_'type'_" value="${webObj.searchValue.type }"/>
					  <input type="text" name="searchValue['title']" id="searchValue_title_" value="${webObj.searchValue.title }" class="form-control input-sm" style="width: 300px;" placeholder="标题，副标题，关键字，摘要，来源"/>
					  <button type="button" class="btn btn-primary btn-sm" onclick="search('');">搜索</button>
					  <button type="button" class="btn btn-default btn-sm glyphicon glyphicon-picture" onclick="searchByType('pic',this)">&nbsp;图片新闻</button>
					  <button type="button" class="btn btn-default btn-sm glyphicon glyphicon-text-size" onclick="searchByType('word',this)">&nbsp;文字新闻</button>
				    </div>
				  </td>
				  <td align="right">
				    <div class="form-group">
				      <h:permission module="xxx_xxx" operation="add">
				        <button type="button" class="btn btn-primary btn-sm" onclick="showAddModal(addUrl,'pic')"><i class="fa fa-plus-circle"></i> 新增图片新闻</button>
				      </h:permission>
				      <h:permission module="xxx_xxx" operation="add">
				        <button type="button" class="btn btn-primary btn-sm" onclick="showAddModal(addUrl,'word')"><i class="fa fa-plus-circle"></i> 新增文字新闻</button>
				      </h:permission>
				      <h:permission module="xxx_xxx" operation="del">
				        <button type="button" class="btn btn-primary btn-sm" onclick="selectAll(this)"><i class="fa fa-check-square"></i>全部选择</button>
				        <button type="button" class="btn btn-primary btn-sm" onclick="defaultEvent('del')"><i class="fa fa-trash"></i>批量删除</button>
				      </h:permission>
				    </div>
				  </td>
				</tr>
			</table>
			<div class="picList js-listEdit">
			  <ul class="mod-itemsLi clearfix" id="NEWS-LIST">
			  	<li id="lastNewsInfo" style="display: none;"></li>
			  </ul>
			</div>
			<div id="DATA-TEMPLATE" style="display: none;">
				<li id="li-%newsinfo.id%" onmousemove="mve(this)" onmouseout="mot(this)" style="width: 285px;height: 300px;">
					<dl>
			  		  	<dt class="mod-itemsTitle">
			  		  		<h3>%newsinfo.title%</h3>
			  		  		<p class="mod-itemsTitle-decsr clearfix">
			  		  			<span class="glyphicon %newsinfo.stateIcon% fn-fr" title="%newsinfo.state%">%newsinfo.createTime%</span>
			  		  			&nbsp;&nbsp;%newsinfo.type.icon%
			  		  		</p>
			  		  	</dt>
			  		    <dd class="mod-itemsContent">
			  		      <div id="div_%newsinfo.id%">
			  		      		<img src="%newsinfo.coverPath%" id="cover_%newsinfo.id%" style="width: 265px;height: 175px;"/>
			  		      		%newsinfo.type.number%
			  		      </div>
			  		      <div class="mod-itemContent-info">
			  		      		%newsinfo.nabstract%
			  		      </div>
						  <div name="liSelectItem" class="picList-editGrid-wrap j-popShow" onclick="mck(this)"></div>
			  		      <div class="picList-editGrid j-popShow">
			  		        <input type="hidden" id="%newsinfo.id%" class="j-selectId" name="selectedRow" value="false" />
			  		        <a class="i-edit-btn" href="javascript:FormFunction.showEditModal('%newsinfo.id%')" title="编辑新闻"><i class="fa fa-edit"></i> </a>
			  		        <a class="i-remove-btn" href="javascript:FormFunction.delSingle('%newsinfo.id%',delUrl + '?picsubjectId=%newsinfo.id%');" title="删除新闻"><i class="fa fa-trash"></i> </a>
			  		      </div>
			  		    </dd>
			  		  </dl>
				</li>
			</div>
			<!-- 分页  start
			<div class="pagnation" id="pagnation">
				<span class="pageDown-sum">
					<em>共<i>${webObj.pageNo+1}</i>条记录</em>  
					<em>当前第 <i>${webObj.pageSize}</i>页 </em>
					<i>/</i>
					共  <i>3</i>页
				</span>
				<a href="#" class="page-prev">上一页</a>
				<a href="#" class="current">1</a>
				<a href="#">2</a>
				<a href="#">3</a>
				<a href="#">4</a>
				<a href="#">5</a>
				<span class="page-items">...</span>
				<a href="#">666</a>
				<a href="#" class="page-next">下一页</a>
			</div>
			分页 end-->
		<div class="pagnation" id="pagnation"></div>
		</div>
		<%@ include file="/base/jsp/common/CommonListFoot.jsp"%>
		<script src="${ctx}/base/imgsel/js/img.js" type="text/javascript"></script>
		<script>
		// number of selected items
		function counter() {
		  if ($('li.selected').length > 0)
		    $('.send').addClass('selected');
		  else
		    $('.send').removeClass('selected');
		  	$('.send').attr('data-counter',$('li.selected').length);
		}
		function openColumns() {
			var treeNewsColumnsViewUrl = "${ctx}/path/newscolumns/treenewscolumns";
			ModalUtil.showModal('treeDlg', treeNewsColumnsViewUrl,'treeNewsColumnsViewModal', function() {
				$.post("<%=ctx%>/path/newscolumns/loadtreenewscolumns", {},
					function(result) {
						if (result.state == 'Success') {
							$('#treeNewsColumns').treeview({
								data : result.content,
								levels : 5,
								nodeIcon:"glyphicon glyphicon-stop",
								onNodeSelected: function(event, data) {
									setColumnsValue4Search(data);
						 	 		closeNewsColumnsWindow();
						 	 	}
							});
						} else {
							bootbox.alert("<h4>操作失败,原因："+result.content+"</h4>", function() {
								closeNewsColumnsWindow();
							});
						}
					}
				);
			});
		}
		function setColumnsValue4Search(data) {
			$("#newsColumnsId4Search").val(data.id);
			$("#newsColumnsName4Search").val(data.text);
		}
		
		</script>
		<div id="myDlg"></div>
		<div id="treeDlg"></div>
	</body>
</html>
